package com.cavy.platform.server.controller;

import com.cavy.platform.server.ResultInfo;
import com.cavy.platform.server.dto.WorkSpaceCreateDto;
import com.cavy.platform.server.dto.WorkSpaceDeleteDto;
import com.cavy.platform.server.dto.WorkSpaceDto;
import com.cavy.platform.server.service.WorkSpaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 工作空间控制器
 * author: 唐旭
 */
@RequestMapping("/workSpace")
@RestController
public class WorkSpaceController {

    @Autowired
    private WorkSpaceService service;

    //创建工作空间
    @PostMapping("create")
    public ResultInfo create(@RequestBody @Valid WorkSpaceCreateDto createDto) {
        service.create(createDto);
        return ResultInfo.newSuccess();
    }

    //删除工作空间
    @PostMapping("delete")
    public ResultInfo delete(@RequestBody @Valid WorkSpaceDeleteDto name) {
        service.delete(name);
        return ResultInfo.newSuccess();
    }

    //工作空间列表`
    @GetMapping("list")
    public List<WorkSpaceDto> list() {
        return service.list();
    }
}
